Skip to content

Conversation

@Moddingear
Copy link

Title says it all. Also moved some code to avoid duplicate function contents.

This isn't really necessary, as atan2 is only used for linear hall sensors. Might only be useful for the end user.

@runger1101001
Copy link
Member

Hey, wasn’t expecting this one :-)

Not sure I like it in this form. Not many people use the CORDIC, but on the G4 MCUs that have it it’s a good solution and improves performance.

the whole sine/cosine thing is a part of SimpleFOC that’s optimized, at least a bit… so changes here would have to come with some timing measurements to demonstrate the impact/improvement.

But hardly anyone uses linear halls, that’s a fringe thing. So I would not be inclined to take any performance hit on the regular code just to have a gain on the linear halls.

A way around this might be to have the atan function set up the CORDIC for atan before its operation and restore it to sin/cos afterwards.

And not to include the code optimization that eliminates duplicate code as this prioritizes code cleanliness over performance, but in this case the duplication was intentional to avoid the extra function call and associated stack manipulation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants